<template>
	<view v-if="token">
		<image @tap.stop="getShow" class="home_img" :src='STATIC_URL+"83.png"' mode="aspectFill"></image>
		<u-popup v-model="show" mode="left" z-index="999">
			<view class="my_popup">
				<scroll-view class="scrollView" :scroll-y="true" :style="{height: scrollHeight + 'px'}">
					<view class="titleView">
						<view class="title_item" @tap.stop="goHome">
							<image :src='STATIC_URL+"85.png"' mode=""></image>
							<text>首页</text>
						</view>
						<view class="title_item" @tap.stop="goMy" v-if="myUser.sex == 2">
							<image :src='STATIC_URL+"86.png"' mode=""></image>
							<text>我的</text>
						</view>
					</view>
					<view class="content_one">
						<view class="one_item" @tap.stop="goNews">
							<view class="one_item_left">
								<image :src='STATIC_URL+"87.png"' mode=""></image>
								<text>消息</text>
							</view>
							<view class="one_item_right">
								<text class="one_item_right_1">{{numInfo.unread_nums}}</text>
								<text class='fu-iconfont2  one_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="one_item" @tap.stop="goFollow">
							<view class="one_item_left">
								<image :src='STATIC_URL+"88.png"' mode=""></image>
								<text>我的关注</text>
							</view>
							<view class="one_item_right">
								<text class="one_item_right_1">{{numInfo.follow_nums}}</text>
								<text class='fu-iconfont2  one_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="one_item" @tap.stop="goBrowse">
							<view class="one_item_left">
								<image :src='STATIC_URL+"89.png"' mode=""></image>
								<text>浏览记录</text>
							</view>
							<view class="one_item_right">
								<text class="one_item_right_1">{{numInfo.foot_nums}}</text>
								<text class='fu-iconfont2  one_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="one_item" @tap.stop="goFabu" v-if="myUser.user_type != 1">
							<view class="one_item_left">
								<image :src='STATIC_URL+"90.png"' mode=""></image>
								<text>我的发布</text>
							</view>
							<view class="one_item_right">
								<text class="one_item_right_1">{{numInfo.comm_nums}}</text>
								<text class='fu-iconfont2  one_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
					</view>
					<view class="content_one">
						<view class="two_more">
							更多
						</view>
						<view class="two_item" @tap.stop="goVip" v-if="myUser.user_type != 1 && myUser.sex == 2">
							<view class="two_item_left">
								<text>我的会员</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goGuanggao" v-if="myUser.user_type != 1 && myUser.sex == 2 && ad_status == 1">
							<view class="two_item_left">
								<text>广告管理</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goFabus" v-if="myUser.user_type != 1">
							<view class="two_item_left">
								<text>发布生活服务</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<template v-if="myUser.user_type != 1 && myUser.sex == 2">
							<view class="two_item" @tap.stop="myAgent" v-if="is_open_agent == 1">
								<view class="two_item_left">
									<text>我的代理</text>
								</view>
								<view class="two_item_right">
									<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
								</view>
							</view>
							<view class="two_item" @tap.stop="goDaili" v-else>
								<view class="two_item_left">
									<text>申请代理</text>
								</view>
								<view class="two_item_right">
									<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
								</view>
							</view>
						</template>
						

						<view class="two_item" @tap.stop="goAuthentication" v-if="myUser.user_type != 1 && myUser.sex == 2">
							<view class="two_item_left">
								<text>我的认证</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goBlack" v-if="myUser.user_type != 1">
							<view class="two_item_left">
								<text>黑名单管理</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goFeekbook">
							<view class="two_item_left">
								<text>意见反馈</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goContact">
							<view class="two_item_left">
								<text>联系我们</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goSetting" v-if="myUser.user_type != 1">
							<view class="two_item_left">
								<text>安全设置</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="goLaw">
							<view class="two_item_left">
								<text>文本和法律条件</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
						<view class="two_item" @tap.stop="loginOut" v-if="myUser.user_type == 1">
							<view class="two_item_left">
								<text>退出登录</text>
							</view>
							<view class="two_item_right">
								<text class='fu-iconfont2  two_item_right_2'>&#xE7F2;</text>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		
		<benben-popup v-model="popupShow1681268717363" :mask="true" mode='center'>
			<view class="flex flex-direction flex-wrap align-center system_flex_3">
				<text class='system_fd3_0'>提示</text>
				<text class='system_fd3_1'>确定退出当前账号？</text>
				<view class='flex flex-wrap align-center system_fd3_2'>
					<button class='system_fd3_2_c0' @tap.stop="popupShow1681268717363=false">取消</button>
					<button class='system_fd3_2_c1' @tap.stop="logOutFunc()">确定</button>
				</view>
			</view>
		</benben-popup>
	</view>
	<view v-else></view>
</template>

<script>
	export default {
		data() {
			return {
				popupShow1681268717363: false,
				show: false,
				scrollHeight: 0,
				is_open_agent: 0,  // 1成功
				numInfo: {},
				myUser: global.userInfo,
				token: "",
				ad_status: 0,  // 广告申请状态
			}
		},
		created() {
			this.token = global.token;
			if (global.token) {
				this.getuser();
				this.getNewsNum();
				this.getAdStatus();
			}
			
			this.scrollHeight = uni.getSystemInfoSync().windowHeight;
			var pages = getCurrentPages() // 获取栈实例
			let currentRoute = pages[pages.length - 1].route; // 获取当前页面路由
			// console.log("路由当前页面路径" + currentRoute)
			console.log(this.myUser);
		},
		watch: {
			show() {
				if (this.show) {
					this.$emit('showPopup');
				} else {
					this.$emit('hidePopup');
				}
			},
		},
		methods: {
			// 查询广告申请状态  post65ddb4e341c78
			getAdStatus() {
				this.$api.post(global.apiUrls.post65ddb4e341c78, {
					
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.ad_status = res.data.data.status;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			
			// 消息数量  post643915f22d9ed
			getNewsNum() {
				this.$api.post(global.apiUrls.post643915f22d9ed, {
					
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.numInfo = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 认证状态  is_open_agent
			async getuser() {
				let id1 = uni.getStorageSync("USER_INFO");
				this.userid = id1.id
				let res = await this.$api.post(global.apiUrls.userinfo, {
					user_id: this.userid,
				});
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.is_open_agent = res.data.data.is_open_agent;
			},
			getShow() {
				this.show = !this.show;
			},
			
			
			// 我的消息
			goNews() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/home/myNews/myNews'
				})
			},
			// 我的关注
			goFollow() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/my/followList/followList'
				})
			},
			// 查看浏览记录
			goBrowse() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/home/browsHistory/browsHistory'
				})
			},
			// 我的发布
			goFabu() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/home/myPosts/myPosts'
				})
			},
			goFabus() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/my/fabu/fabu'
				})
			},
			// 首页
			goHome() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/tabBar/index/index'
				})
			},
			// 我的
			goMy() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/tabBar/my/my'
				})
			},
			// 联系我们
			goContact() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/xtsz/contactUs/contactUs'
				})
			},
			// 安全设置
			goSetting() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/xtsz/cardAndSafe/cardAndSafe'
				})
			},
			// 意见反馈
			goFeekbook() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/xtsz/iNeedFeedback/iNeedFeedback'
				})
			},
			// 黑名单管理
			goBlack() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/xtsz/setBlacklist/setBlacklist'
				})
			},
			// 我的认证
			goAuthentication() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/my/authentication/authentication'
				})
			},
			// 广告管理
			goGuanggao() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/my/advertisementManage/advertisementManage'
					// url: '/pages/my/adList/adList'
				})
			},
			// 我的会员
			goVip() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/qbgl/vip/vip'
				})
			},
			// 申请代理
			goDaili() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/qbgl/agentInfo/agentInfo'
				})
			},
			// 我的代理
			myAgent() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/qbgl/agentApplication/agentApplication'
				})
			},
			// 法律法规
			goLaw() {
				this.show = false;
				uni.navigateTo({
					url: '/pages/dlzc/conceal/conceal?type=7'
				})
			},
			loginOut() {
				this.show = false;
				this.popupShow1681268717363 = true;
			},
			
			//退出登录
			logOutFunc() {
				this.tim.logout();
				this.$store.commit('logout');
				// #ifdef APP-PLUS
				this.TUICallKit.logout();
				// #endif
				uni.reLaunch({
					url: '/pages/tabBar/login/login'
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.home_img {
		width: 40rpx;
		height: 40rpx;
	}

	.my_popup {
		width: 630rpx;
		height: 100%;
		background: #F7F7F7;
		position: relative;
		z-index: 999;

		.scrollView {
			padding: 40rpx 32rpx;

			.titleView {
				display: flex;
				justify-content: space-between;

				.title_item {
					width: 267rpx;
					height: 88rpx;
					background: #FFFFFF;
					border-radius: 10rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					image {
						width: 40rpx;
						height: 40rpx;
					}

					text {
						font-size: 36rpx;
						font-weight: bold;
						margin-left: 20rpx;
					}
				}
			}

			.content_one {
				padding: 0 24rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				margin-top: 32rpx;

				.one_item {
					padding: 32rpx 0;
					border-bottom: 1px solid #eee;
					display: flex;
					justify-content: space-between;

					.one_item_left {
						display: flex;
						align-items: center;
						font-size: 32rpx;

						image {
							width: 48rpx;
							height: 48rpx;
							margin-right: 24rpx;
						}
					}

					.one_item_right {
						display: flex;
						align-items: center;

						.one_item_right_1 {
							font-size: 26rpx;
							color: #D5262E;
							margin-right: 16rpx;
						}

						.one_item_right_2 {
							font-size: 22rpx;
							color: #D6D6D6;
						}
					}
				}

				.two_item {
					padding: 24rpx 0;
					display: flex;
					justify-content: space-between;

					.two_item_left {
						display: flex;
						align-items: center;
						font-size: 32rpx;

						image {
							width: 48rpx;
							height: 48rpx;
							margin-right: 24rpx;
						}
					}

					.two_item_right {
						display: flex;
						align-items: center;

						.two_item_right_1 {
							font-size: 26rpx;
							color: #D5262E;
							margin-right: 16rpx;
						}

						.two_item_right_2 {
							font-size: 22rpx;
							color: #D6D6D6;
						}
					}
				}

				.two_more {
					font-size: 26rpx;
					color: #999;
					padding: 32rpx 0;
					border-bottom: 1px solid #eee;
				}
			}
		}
	}
	.system_flex_3 {
		background: #fff;
		width: 540rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	
	.system_fd3_2_c1 {
		border-top: 1px solid #eee;
		border-left: 1px solid #eee;
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: rgba(0, 0, 0, 1.0);
		width: 270rpx;
	}
	
	.system_fd3_2_c0 {
		border-top: 1px solid #eee;
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 0rpx 103rpx 0rpx 103rpx;
	}
	
	.system_fd3_2 {
		margin: 37rpx 0rpx 0rpx 0rpx;
	}
	
	.system_fd3_1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}
	
	.system_fd3_0 {
		font-size: 36rpx;
		font-weight: 800;
		line-height: 44rpx;
		color: #333333;
		margin: 40rpx 0rpx 40rpx 0rpx;
	}
</style>